#ifndef INCREMENTAL_SEARCH_H_INCLUDED
#define INCREMENTAL_SEARCH_H_INCLUDED

#include <M_Code_plugin.h>
#include <wx/wxscintilla.h>

class cbStyledTextCtrl;
class wxComboCtrl;
class cbIncSearchComboPopUp;

class IncrementalSearch : public M_Code_Plugin {
  public:
    IncrementalSearch();
    ~IncrementalSearch();
    int GetConfigurationPriority() const {
      return 50;
    }
    int GetConfigurationGroup() const {
      return cgEditor;
    }
    cbConfigurationPanel* GetConfigurationPanel( wxWindow* parent );
    cbConfigurationPanel* GetProjectConfigurationPanel( wxWindow*, M_Code_Project* ) {
      return 0;
    }
    void BuildMenu( wxMenuBar* menuBar );
    void BuildModuleMenu( const ModuleType, wxMenu*, const FileTreeData*  = 0 ) {}
    bool BuildToolBar( wxToolBar* toolBar );
    void SetMaxHistoryLen( int len );
  private:
    void OnAttach();
    void OnRelease( bool appShutDown );
    void OnKeyDown( wxKeyEvent& event );
    void OnFocusToolbar( wxCommandEvent& event );
    void OnTextChanged( wxCommandEvent& event );
    void OnKillFocus( wxCommandEvent& event );
    void OnClearText( wxCommandEvent& event );
    void OnSearchPrev( wxCommandEvent& event );
    void OnSearchNext( wxCommandEvent& event );
    void OnToggleToolbar( wxCommandEvent& event );
    void OnEditorEvent( CodeBlocksEvent& event );
    void OnToggleHighlight( wxCommandEvent& event );
    void OnToggleSelectedOnly( wxCommandEvent& event );
    void OnToggleMatchCase( wxCommandEvent& event );
    void OnToggleUseRegex( wxCommandEvent& event );
    void DoClearText();
    void DoSearchPrev();
    void DoSearchNext();
    void DoToggleHighlight( bool checked );
    void DoToggleSelectedOnly( bool checked );
    void DoToggleMatchCase( bool checked );
    void DoToggleUseRegex( bool checked );
    void DoFocusToolbar();
    void HighlightText();
    void SearchText();
    void DoSearch( int fromPos, int startPos = wxSCI_INVALID_POSITION, int endPos = wxSCI_INVALID_POSITION );
    void VerifyPosition();
    void SetRange();
    void OnMenuEditPaste( wxCommandEvent& event );
    wxString m_SearchText;
    wxColour m_textCtrlBG_Default;
    wxToolBar* m_pToolbar;
    wxComboCtrl* m_pComboCtrl;
    wxTextCtrl* m_pTextCtrl;
    cbIncSearchComboPopUp* m_pChoice;
    M_Code_Editor* m_pEditor;
    int m_NewPos;
    int m_OldPos;
    int m_SelStart;
    int m_SelEnd;
    int m_MinPos;
    int m_MaxPos;
    int m_flags;
    bool m_Highlight;
    bool m_SelectedOnly;
    const int m_IndicFound;
    const int m_IndicHighlight;
    int m_LengthFound;
    long m_LastInsertionPoint;
    DECLARE_EVENT_TABLE()
};

#endif
